﻿using System;
using System.IO;
using System.Net;

namespace MockingBird.Wsdl.Parser
{
    public class WsdlRetrieverSettings : IWsdlRetrieverSettings
    {
        public ICredentials Credentials { get; set; }
        public string DownloadLocationRoot { get; set; }

        public bool HasNonInitializedValues
        {
            get
            {
                if ((this.Credentials == null) || (String.IsNullOrEmpty(this.DownloadLocationRoot)))
                {
                    return true;
                }
                else
                {
                    return false;
                }
            }
        }

        public void SetDefaults(string serviceName)
        {
            //Set the default credentials to be the default credentials from the credential cache
            if (this.Credentials == null)
            {
                this.Credentials = CredentialCache.DefaultCredentials;
            }
            //set the root location of the download folder if not already provided

            if (string.IsNullOrEmpty(this.DownloadLocationRoot))
            {
                this.DownloadLocationRoot = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData),
                                                         @"MockingBird\WsdlParser\");
                this.DownloadLocationRoot = Path.Combine(this.DownloadLocationRoot, serviceName);

            }
        }


    }
}
